/**
 * [OElove] (C)2010-2099 OELOVE.COM Inc.biz
 * Email: service@phpcoo.com ,phpcoo@qq.com
 * This is NOT a freeware, use is subject to license terms
 * $ Last update 2017/05/10 by CL $
*/
$(function(){

	//搜索选择器
	$(document).on("click", "[f='but_selser']", function(){
		$_dd = $(this).next("dd");
		if ($_dd.css("display") == "none") {
			$(this).parent().addClass("current");
			$_dd.slideDown(100);
		}
		else {
			$(this).parent().removeClass("current");
			$_dd.slideUp(100);
		}
	});
	
	//点击空白出隐藏选择器
	$(document).on("click", function(e){
		var target1  = $(e.target);
        if(target1.closest(".oe_search dl").length == 0){
			$(".oe_search dl dd").slideUp(100);
			$(".oe_search dl").removeClass("current");
		}
	});

	//下拉选1项 change
	$(document).on("change", "[f='but_sel_one']", function(){
		$_val = $(this).find("option:selected").val();
		$_text = $(this).find("option:selected").text();
		$_tips_text = $(this).attr("data-tips");
		if (typeof($_tips_text) == "undefined") {
			$_tips_text = "不限";
		}
		if ($_text == "=不限=") {
			$_text = $_tips_text;
		}
		$(this).parent().prev().children("em").html($_text);
		$(this).parent().slideUp(100);
		$(this).parent().parent().removeClass("current");
	});

	//范围确定选择2项及以上
	$(document).on("click", "[f='but_selrange_confirm']", function(){
		$_val1 = $_text1 = $_val2 = $_text2 = $_val3 = $_text3 = $_val4 = $_text4 = "";
		$_data_1 = $(this).attr("data-1");
		$_data_2 = $(this).attr("data-2");

		$_data_3 = $(this).attr("data-3");
		if (typeof($_data_3) == "undefined") {
			$_data_3 = "";
		}
		$_data_4 = $(this).attr("data-4");
		if (typeof($_data_4) == "undefined") {
			$_data_4 = "";
		}
		$_data_unit = $(this).attr("data-unit");
		$_data_tips = $(this).attr("data-tips");
		if (typeof($_data_unit) == "undefined") {
			$_data_unit = "";
		}
		if (typeof($_data_tips) == "undefined") {
			$_data_tips = "";
		}

		if ($_data_1.length > 0) {
			$_val1 = parseInt($("#"+$_data_1).find("option:selected").val());
			$_text1 = $("#"+$_data_1).find("option:selected").text();
		}
		if ($_data_2.length > 0) {
			$_val2 = parseInt($("#"+$_data_2).find("option:selected").val());
			$_text2 = $("#"+$_data_2).find("option:selected").text();
		}
		
		if ($_data_3.length > 0) {
			$_val3 = parseInt($("#"+$_data_3).find("option:selected").val());
			$_text3 = $("#"+$_data_3).find("option:selected").text();
		}
		if ($_data_4.length > 0) {
			$_val4 = parseInt($("#"+$_data_4).find("option:selected").val());
			$_text4 = $("#"+$_data_4).find("option:selected").text();
		}


		if ($_val1 > 0 && $_val2 > 0) {
			$_text = $_text1+$_data_unit+"-"+$_text2+$_data_unit;

			if ($_val3 > 0) {
				$_text = $_text+"-"+$_text3+$_data_unit;
			}
			if ($_val4 > 0) {
				$_text = $_text+"-"+$_text4+$_data_unit;
			}
		}
		else {
			$_text = $_data_tips;
		}
		$(this).parent().parent().prev().children("em").html($_text);
		$(this).parent().parent().slideUp(100);
		$(this).parent().parent().parent().removeClass("current");

	});

	
	//热门标签
	$("[f='but_ser_tag']").on("click", function(){
		$_val = $(this).attr("data-val");
		$_power = $(this).attr("data-power");
		if (_LOGIN_STATUS == "0") {
			_jdLogin();
			return false;
		}
		else {
			//没有权限
			if ($_power == "0") {
				$("#ser_nopower_data").find(".content").hide();
				if ($_val == "rz") {
					$("#rz_cont_tips").show();
				}
				else if ($_val == "bailing") {
					$("#profile_cont_tips").show();
				}
				else if ($_val == "gaoxueli") {
					$("#profile_cont_tips").show();
				}
				else if ($_val == "vip") {
					$("#vip_cont_tips").show();
				}
				oeOpenDiv("ser_nopower");
				return false;
			}
			else {
				$("#s_tag").val($_val);
				$("#user_form").submit();
			}
		}
		
	});

	//附近的人
	$("[f='but_search_map']").on("click", function(){
		$_val = $(this).attr("data-val");
		$("#s_map").val($_val);
		$("#user_form").submit();
	});

	//排序
	$("[f='but_ser_orderby']").on("click", function(){
		$_val = $(this).attr("data-val");
		$("#s_orderby").val($_val);
		$("#user_form").submit();
	});

	//切换模式
	$("[f='but_ser_showtype']").on("click", function(){
		$_val = $(this).attr("data-val");
		$("#s_showtype").val($_val);
		$("#user_form").submit();
	});


	//搜索按钮
	$(document).on("click", "[f='but_confirm_userser']", function(){
		$("#user_form").submit();
	});


	//展开更多搜索条件
	$(document).on("click", "[f='but_open_more']", function(){
		if (_LOGIN_STATUS == "1") {
			if (_ADVSER_POWER == "1") {
				if ($(this).hasClass("current")) {
					$("#more_advser_box").slideUp(100);
					$(this).removeClass("current");
					$(this).html("展开更多条件<i></i>");
				}
				else {
					$("#more_advser_box").slideDown(100);
					$(this).addClass("current");
					$(this).html("收起更多条件<i></i>");
				}
			}
			else {
				$("#ser_nopower_data").find(".content").hide();
				$("#adv_cont_tips").show();
				oeOpenDiv("ser_nopower");
			}
		}
		else {
			//打开登录窗
			_jdLogin();
		}
	});

	//头像模式显示隐藏二维码
	$(document).on("mouseover", "[f='but_show_user_qrcode']", function(){
		$_id = $(this).attr("data-id");
		$_att = $(this).attr("data-att");
		if (typeof($_att) == "undefined") {
			$_att = "";
		}
		$_url = _ROOT_PATH+"index.php?c=scan&a=scan&mod=home&id="+$_id+"&r="+get_rndnum(8);
		$_status = $("#qrcode_"+$_id+$_att+" p").first().find("img").attr("data-status");

		if (typeof($_status) == "undefined") {
			$_status = "";
		}
		if ($_status.length == 0) {
			$("#qrcode_"+$_id+$_att+" p").first().find("img").attr("src", $_url);
			$("#qrcode_"+$_id+$_att+" p").first().find("img").attr("data-status", "ok");
			$("#qrcode_"+$_id+$_att).show();
		}
		else {
			$("#qrcode_"+$_id+$_att).show();
		}
	
	});
	$(document).on("mouseout", "[f='but_show_user_qrcode']", function(){
		$_id = $(this).attr("data-id");
		$_att = $(this).attr("data-att");
		if (typeof($_att) == "undefined") {
			$_att = "";
		}
		$("#qrcode_"+$_id+$_att).hide();
	});


	//独白模式显示隐藏二维码
	$(document).on("mouseover", "[f='but_show_moreuser_qrcode']", function(){
		$_id = $(this).attr("data-id");
		$_att = $(this).attr("data-att");
		if (typeof($_att) == "undefined") {
			$_att = "";
		}

		$_url = _ROOT_PATH+"index.php?c=scan&a=scan&mod=home&id="+$_id+"&r="+get_rndnum(8);
		$_status = $("#qrcode_"+$_id+$_att+" img").attr("data-status");
		if (typeof($_status) == "undefined") {
			$_status = "";
		}
		if ($_status.length == 0) {
			$("#qrcode_"+$_id+$_att+" img").attr("src", $_url);
			$("#qrcode_"+$_id+$_att+" img").attr("data-status", "ok");
			$("#qrcode_"+$_id+$_att).show();
		}
		else {
			$("#qrcode_"+$_id+$_att).show();
		}

	});
	$(document).on("mouseout", "[f='but_show_moreuser_qrcode']", function(){
		$_id = $(this).attr("data-id");
		$_att = $(this).attr("data-att");
		if (typeof($_att) == "undefined") {
			$_att = "";
		}
		$("#qrcode_"+$_id+$_att).hide();
	});

	//显示隐藏发私信按钮
	$(document).on("mouseover", "[f='pop_send_msg']", function(){
		if (!$(this).hasClass("current")) {
			$(this).addClass("current");
		}
	});
	$(document).on("mouseout", "[f='pop_send_msg']", function(){
		if ($(this).hasClass("current")) {
			$(this).removeClass("current");
		}
	});

	//点击查看个人名片 JSON 7.03.24
	$(document).on("click", "[f='but_open_usercard']", function(){
		$_id = $(this).attr("data-uid");
		$_url = _ROOT_PATH+"index.php?c=home&a=card&id="+$_id+"&r="+get_rndnum(8);
		oeCardShadeBox("pop_usercard", $_url, 740, 522);
	});


	//新的下拉选择 7.05.10
	$(document).on("change", "[f='but_change_sel']", function(){
		$tid = $(this).attr("data-tid");
		$text = $(this).find("option:selected").text();

		$("#"+$tid).html($text);
	});
	//新的选择地区 7.05.10
	$(document).on("click", "[f='but_selarea_confirm']", function(){
		$_val1 = $_text1 = $_val2 = $_text2 = $_val3 = $_text3 = $_val4 = $_text4 = $_text =  "";
		$_val1 = $("#s_dist1").val();
		$_val2 = $("#s_dist2").val();
		$_val3 = $("#s_dist3").val();
		if (typeof($_val3) == "undefined") {
			$_val3 = "";
		}
		$_val4 = $("#s_dist4").val();
		if (typeof($_val4) == "undefined") {
			$_val4 = "";
		}

		if ($_val1.length > 0) {
			$_text1 = $("#s_dist1").find("option:selected").text();
		}
		if ($_val2.length > 0) {
			$_text2 = $("#s_dist2").find("option:selected").text();
		}
		if ($_val3.length > 0) {
			$_text3 = $("#s_dist3").find("option:selected").text();
		}
		if ($_val4.length > 0) {
			$_text4 = $("#s_dist4").find("option:selected").text();
		}
		if ($_val1 > 0) {
			$_text = $_text1+"-"+$_text2;

			if ($_val3 > 0) {
				$_text = $_text+"-"+$_text3;
			}
			if ($_val4 > 0) {
				$_text = $_text+"-"+$_text4;
			}
		}
		$("#s_dist_text").html($_text);
		$("#selarea_box").hide();
	});
	$(document).on("click", "#s_dist_text", function(){
		if ($("#selarea_box").css("display") == "none") {
			$("#selarea_box").show();
		}
		else {
			$("#selarea_box").hide();
		}
	});
	
});

